package org.turman.buobaobook.model;

public class ResponseBean<T> {
    public static final String SUCCESS_CODE = "200";
    public static final String FAIL_CODE = "500";

    private String code;
    private String msg;
    private T data;

    public static <T> ResponseBean success(T data) {
        return new ResponseBean<T>(SUCCESS_CODE, "success", data);
    }

    public static <T> ResponseBean success() {
        return new ResponseBean<T>(SUCCESS_CODE, "success");
    }

    public static <T> ResponseBean fail(String code, String msg) {
        return new ResponseBean<T>(code, msg);
    }

    public static <T> ResponseBean fail( String msg) {
        return new ResponseBean<T>(FAIL_CODE, msg);
    }

    public ResponseBean(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseBean(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
